# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.Compute.V1.Model.CustomErrorResponsePolicyCustomErrorResponseRule do
  @moduledoc """
  Specifies the mapping between the response code that will be returned along with the custom error content and the response code returned by the backend service.

  ## Attributes

  *   `matchResponseCodes` (*type:* `list(String.t)`, *default:* `nil`) - Valid values include: - A number between 400 and 599: For example 401 or 503, in which case the load balancer applies the policy if the error code exactly matches this value. - 5xx: Load Balancer will apply the policy if the backend service responds with any response code in the range of 500 to 599. - 4xx: Load Balancer will apply the policy if the backend service responds with any response code in the range of 400 to 499. Values must be unique within matchResponseCodes and across all errorResponseRules of CustomErrorResponsePolicy.
  *   `overrideResponseCode` (*type:* `integer()`, *default:* `nil`) - The HTTP status code returned with the response containing the custom error content. If overrideResponseCode is not supplied, the same response code returned by the original backend bucket or backend service is returned to the client.
  *   `path` (*type:* `String.t`, *default:* `nil`) - The full path to a file within backendBucket . For example: /errors/defaultError.html path must start with a leading slash. path cannot have trailing slashes. If the file is not available in backendBucket or the load balancer cannot reach the BackendBucket, a simple Not Found Error is returned to the client. The value must be from 1 to 1024 characters
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :matchResponseCodes => list(String.t()) | nil,
          :overrideResponseCode => integer() | nil,
          :path => String.t() | nil
        }

  field(:matchResponseCodes, type: :list)
  field(:overrideResponseCode)
  field(:path)
end

defimpl Poison.Decoder,
  for: GoogleApi.Compute.V1.Model.CustomErrorResponsePolicyCustomErrorResponseRule do
  def decode(value, options) do
    GoogleApi.Compute.V1.Model.CustomErrorResponsePolicyCustomErrorResponseRule.decode(
      value,
      options
    )
  end
end

defimpl Poison.Encoder,
  for: GoogleApi.Compute.V1.Model.CustomErrorResponsePolicyCustomErrorResponseRule do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
